/*
 *  模型由多个部件组成
 *  注意:
 *      1.右手坐标系,模型位于原点,前方x正方向,左边y正方向,头上z正方向
 *      2.输入模型坐标时,建议输入0~1范围的数值,再利用 width、height、depth 来调整大小
 */
#ifndef _3D_MODEL_H_
#define _3D_MODEL_H_

#include <iostream>
#include "3d_atom.h"
#include "image.h"
#include "crosslist.h"

//模型部件
struct D3ModelPart
{
public:
    //顶点个数 & 坐标
    int32_t points;
    float xyz[12];
    //大小,默认为1
    float width; //宽(y轴)
    float height; //高(z轴)
    float depth; //深度(x轴)
    //填充
    uint32_t color; //纯色填充
    ImageGrid *grid; //图片填充

    D3ModelPart(float *xyz, int32_t points, uint32_t color = 0, ImageGrid *grid = NULL);
    void Print();
};

//模型由多个线条、三角平面、四边平面组成
class D3Model
{
public:
    CrossList partList;
    D3Atom sites;

    D3Model();
    ~D3Model();

    //模型顶点构建,返回在 partList 子链表中的序号, -1失败
    int32_t AddLine(float xyz[6], uint32_t color = 0);
    int32_t AddLine(float x1, float y1, float z1,
                float x2, float y2, float z2,
                uint32_t color = 0);

    int32_t AddTriangle(float xyz[9], uint32_t color = 0);
    int32_t AddTriangle(float x1, float y1, float z1,
                    float x2, float y2, float z2,
                    float x3, float y3, float z3,
                    uint32_t color = 0);

    int32_t AddRect(float xyz[12], uint32_t color = 0, ImageGrid *grid = NULL);
    int32_t AddRect(float x1, float y1, float z1,
                float x2, float y2, float z2,
                float x3, float y3, float z3,
                float x4, float y4, float z4,
                uint32_t color = 0, ImageGrid *grid = NULL);

    //整体缩放,取值范围: 0.0 ~ 缩放区间 ~ 1.0 ~ 放大区间 ~ XXX
    //在模型构建完毕后使用,否则后续添加进来的 part 未参与缩放
    void Zoom(float multiple);
};

#endif // _3D_MODEL_H_
